package cn.liumouren.jzxd.dao;

import cn.liumouren.jzxd.entity.Zone;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Freeman Liu
 * @email llw599502537@gmail.com
 * @date 2020-10-30 16:28:21
 */
@Mapper
public interface ZoneDao extends BaseMapper<Zone> {

    @Select("SELECT tb_zone.* FROM `tb_likes`,`tb_zone` WHERE tb_likes.`zone_id` = tb_zone.`id` AND `tb_likes`.`user_id` = #{userId} ORDER BY `tb_likes`.`add_time` DESC")
    IPage<Zone> getLikedZonesByUserId(String userId, IPage<Zone> page);

    @Select("SELECT tb_zone.* FROM `tb_comment`,`tb_zone` WHERE tb_comment.`zone_id` = tb_zone.`id` AND `tb_comment`.`user_id` = #{userId} ORDER BY `tb_comment`.`add_time` DESC")
    IPage<Zone> getCommentedZonesByUserId(IPage<Zone> page, String userId);
}
